<?php include("DbConn.php");
      include("QuestionAssembler.php");

class QuestionFactory
{
   public function makeNewQuestion($userId, $problemId) {
      $db = QuestionDbWriter::getInstance();
      $dataDef = $db->getDefinitionFromDb($problemId);
      $questionAssembler = new QuestionAssembler();
      $questionAssembler->build($dataDef);
      $question = $questionAssembler->getTestQuestion();
      $question->handle = $userId;
      $db->storeTestQuestion($question);
      return $question;
   }

   public function getUserCurrentQuestion($handle) {
      #return db stuff
      $db = QuestionDbWriter::getInstance();
      return $db->getQuestionFromDb($handle);
   }

   public function updateResults($question) {
      #$this->printResults($question);
      $db = QuestionDbWriter::getInstance();
      $db->removeTestQuestion($question);
      $db->updateUserResults($question);
   }

   private function saveQuestionToDb($question) {
      #save $question to db
      $db = QuestionDbWriter::getInstance();
      $db->storeTestQuestion($question);
   }
}
